home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE6 / PD / PDF / GuiLib / Wimp / h / GuiWimp < prev    next >
Text File  |  2003-02-14  |  7KB  |  226 lines

  1. //--------------------------------------------------------------------------
  2. //
  3. //   Copyright (c) 2002, Colin Granville
  4. //
  5. //   All rights reserved.
  6. //
  7. //   Redistribution and use in source and binary forms, with or
  8. //   without modification, are permitted provided that the following 
  9. //   conditions are met:
  10. //
  11. //      * Redistributions of source code must retain the above copyright 
  12. //        notice, this list of conditions and the following disclaimer.
  13. //
  14. //      * Redistributions in binary form must reproduce the above 
  15. //        copyright notice, this list of conditions and the following 
  16. //        disclaimer in the documentation and/or other materials 
  17. //        provided with the distribution.
  18. //
  19. //      * The name Colin Granville may not be used to endorse or promote 
  20. //        products derived from this software without specific prior 
  21. //        written permission.
  22. //
  23. //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  24. //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  25. //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  26. //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  27. //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  28. //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  29. //   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  30. //   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  31. //   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  32. //   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  33. //   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
  34. //   OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //--------------------------------------------------------------------------
  37.  
  38. #ifndef GuiWimp_h
  39. #define GuiWimp_h
  40.  
  41. #include "GuiWimpSwis.h"
  42. #include "GuiBBox.h"
  43. #include "GuiIcon.h"
  44. #include "GuiWimpWindow.h"
  45. #include "swis.h"
  46.  
  47. //*********************************************************************
  48. //                         Caret
  49. //*********************************************************************
  50.  
  51. class GuiMouseClickBlock
  52. {
  53.   public:
  54.     int x;
  55.     int y;
  56.     int buttons;
  57.     int windowHandle;
  58.     int iconHandle;
  59.    
  60.     void get()    {_swix(Wimp_GetPointerInfo,_IN(1),this);}
  61. };
  62.  
  63.  
  64. #include "GuiWimpMessage.h"
  65.  
  66. class GuiPointerInfo : public GuiMouseClickBlock
  67. {
  68.   public:
  69.     enum {Adjust=1,Menu=2,Select=4};
  70.  
  71.     GuiPointerInfo() {get();}
  72. };
  73.  
  74. //*********************************************************************
  75. //                         Caret
  76. //*********************************************************************
  77.  
  78. class GuiCaretPositionBlock
  79. {
  80.   public:
  81.     int     windowHandle;
  82.     int     iconHandle;
  83.     int     xoffset;
  84.     int     yoffset;
  85.     int     height;
  86.     int     index;
  87.     void    get()   {_swix(Wimp_GetCaretPosition,_IN(1),this);}
  88. };
  89.  
  90.  
  91. class GuiCaretPosition : public GuiCaretPositionBlock
  92. {
  93.   public:
  94.     GuiCaretPosition()   {get();}
  95.     static void set(int window_handle,int icon_handle,int xoffset,int yoffset,int height,int index)
  96.         {_swix(Wimp_SetCaretPosition,_INR(0,5),window_handle,icon_handle,xoffset,yoffset,height,index);}
  97. };
  98.  
  99.  
  100. //*********************************************************************
  101. //                         Drag
  102. //*********************************************************************
  103.  
  104. class GuiDragBox
  105. {
  106.   public:
  107.     enum //dragType
  108.     {
  109.       DragPoint          = 7,
  110.     };
  111.     int         windowHandle;
  112.     int         dragType;
  113.     GuiBBox     draggingBox;
  114.     GuiBBox     parentBox;
  115.     int*        workspace;
  116.     void        (*draw)();
  117.     void        (*remove)();
  118.     void        (*move)();
  119.  
  120.     GuiDragBox()                            {}
  121.     void        startDrag(int drag_type)    {dragType=drag_type;_swix(Wimp_DragBox,_IN(1),this);}
  122.     static void cancelDrag()                {_swix(Wimp_DragBox,_IN(1),0);}
  123. };
  124.  
  125. //***************************************************************************
  126. //*                               Events                                    *
  127. //***************************************************************************
  128.  
  129. class GuiKeyPressedEvent
  130. {
  131.   public:
  132.     GuiCaretPositionBlock caret;
  133.     int                   keyCode;
  134. };
  135.  
  136. class GuiScrollRequestEvent
  137. {
  138.   public:
  139.     struct Open : public GuiWindowPositionBlock
  140.     {
  141.       int  behind;
  142.     } open;
  143.     int                xscroll;
  144.     int                yscroll;
  145.     // because an GuiOpenWindowBlock is extended for the nested wimp
  146.     // a GuiScrollRequestEvent needs to be cast to a GuiWindowOpenBlock
  147.     // for the window show() method
  148.     GuiOpenWindowBlock& openBlock() {return (GuiOpenWindowBlock&)*this;}
  149. };
  150.  
  151. class GuiPollWordNonZeroEvent
  152. {
  153.   public:
  154.     void*  pollWord;
  155.     int    pollWordContents;    
  156. };
  157.  
  158. struct GuiCloseWindowRequestEvent
  159. {
  160.   int windowHandle;
  161. };
  162.  
  163. struct GuiUserDragBoxEvent
  164. {
  165.   GuiBBox bbox;
  166. };
  167.  
  168.  
  169. //event codes returned in r0 from SWI Wimp_Poll
  170.   
  171. #define GuiWimp_ENull                    0
  172. #define GuiWimp_ERedrawWindow            1
  173. #define GuiWimp_EOpenWindow              2
  174. #define GuiWimp_ECloseWindow             3
  175. #define GuiWimp_EPointerLeavingWindow    4
  176. #define GuiWimp_EPointerEnteringWindow   5
  177. #define GuiWimp_EMouseClick              6
  178. #define GuiWimp_EUserDrag                7
  179. #define GuiWimp_EKeyPressed              8
  180. #define GuiWimp_EMenuSelection           9
  181. #define GuiWimp_EScrollRequest           10
  182. #define GuiWimp_ELoseCaret               11
  183. #define GuiWimp_EGainCaret               12
  184. #define GuiWimp_EPollWordNonZero         13
  185. #define GuiWimp_EUserMessage             17
  186. #define GuiWimp_EUserMessageRecorded     18
  187. #define GuiWimp_EUserMessageAcknowledge  19
  188. #define GuiWimp_EToolboxEvent            0x200
  189.  
  190.  
  191. typedef GuiRedrawWindowBlock             GuiRedrawWindowRequestEvent;
  192. typedef GuiOpenWindowBlock               GuiOpenWindowRequestEvent;
  193. typedef GuiCloseWindowRequestEvent       GuiPointerLeavingWindowEvent,
  194.                                          GuiPointerEnteringWindowEvent;
  195. typedef GuiMouseClickBlock               GuiMouseClickEvent;
  196. typedef int                              GuiMenuSelectionEvent[9];
  197. typedef GuiCaretPositionBlock            GuiGainCaretEvent,
  198.                                          GuiLoseCaretEvent;
  199. typedef GuiWimpMessage                   GuiUserMessageEvent,
  200.                                          GuiUserMessageRecordedEvent,
  201.                                          GuiUserMessageAcknowledgeEvent;
  202.  
  203. typedef union
  204. {               
  205.     int                            words[64];
  206.     char                           bytes[256];
  207.     GuiRedrawWindowRequestEvent    redrawWindowRequest;
  208.     GuiOpenWindowRequestEvent      openWindowRequest;
  209.     GuiCloseWindowRequestEvent     closeWindowRequest;
  210.     GuiPointerLeavingWindowEvent   pointerLeavingWindow;
  211.     GuiPointerEnteringWindowEvent  pointerEnteringWindow;
  212.     GuiMouseClickEvent             mouseClick;
  213.     GuiUserDragBoxEvent            userDragBox;
  214.     GuiKeyPressedEvent             keyPressed;
  215.     GuiMenuSelectionEvent          menuSelection;
  216.     GuiScrollRequestEvent          scrollRequest;
  217.     GuiLoseCaretEvent              loseCaret;
  218.     GuiGainCaretEvent              gainCaret;
  219.     GuiPollWordNonZeroEvent        pollWordNonZero;
  220.     GuiUserMessageEvent            userMessage;
  221.     GuiUserMessageRecordedEvent    userMessageRecorded;
  222.     GuiUserMessageAcknowledgeEvent userMessageAcknowledge;
  223. } GuiWimpPollBlock;
  224.  
  225. #endif
  226.